import 'package:flutter/material.dart';

class NotifyItem extends StatefulWidget {
  const NotifyItem({super.key, required this.item});
  // 定义数据
  // { id:1, title: "标题", content: "内容", createAt: "2021-01-01"}
  final Map item;

  @override
  State<NotifyItem> createState() => _NotifyItemState();
}

class _NotifyItemState extends State<NotifyItem> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        // 点击跳转详情页
        Navigator.pushNamed(
          context,
          '/noticeDetail',
          arguments: widget.item["id"],
        );
      },
      child: Container(
        margin: const EdgeInsets.all(10),
        padding: const EdgeInsets.all(10),
        decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(10)),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              widget.item["title"] ?? "",
              textAlign: TextAlign.left,
              style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 18),
            ),
            const SizedBox(height: 10),
            Text(
              widget.item["content"] ?? "",
              textAlign: TextAlign.left,
              style: const TextStyle(color: Color.fromARGB(255, 103, 101, 101), fontSize: 16),
            ),
            const SizedBox(height: 10),
            Text(
              widget.item["createAt"] ?? "",
              textAlign: TextAlign.left,
              style: const TextStyle(color: Color.fromARGB(255, 202, 200, 200), fontSize: 14),
            )
          ],
        ),
      ),
    );
  }
}
